package com.smag.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.smag.common.core.domain.entity.FarmCart;
import com.smag.system.domain.vo.ShoppingCartVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface FarmCartMapper extends BaseMapper<FarmCart> {


    List<ShoppingCartVo> getShoppingCart(Long userId);

    @Update("update farm_cart set amount=#{amount} where user_id=#{userId} and product_id=#{productId}")
    int updateShoppingCart(@Param("userId") Long userId, @Param("productId") Long productId, @Param("amount") Long amount);

    @Select("select *from farm_cart where user_id=#{userId} and product_id=#{productId}")
    FarmCart findShoppingCart(@Param("userId") Long userId,@Param("productId") Long productId);

    @Delete("delete from farm_cart where user_id=#{userId} and product_id=#{productId}")
    int deleteShoppingCart(@Param("userId") Long userId, @Param("productId") Long productId);
}
